package net.zjitc.servlet;

import net.zjitc.domain.User;
import net.zjitc.service.UserService;
import net.zjitc.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author admin
 * @Date 2019/3/7 11:05
 */
@WebServlet(name = "UserUIServlet",urlPatterns = "/userUI")
public class UserUIServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserService service = new UserServiceImpl();
        String id = request.getParameter("uid");
        User user = service.findById(id);
        request.setAttribute("u",user);
        request.getRequestDispatcher("/user.jsp").forward(request,response);
    }
}
